import { centerPoint } from '@/config';

export function createMap(containerId = 'container') {
  const TMap = (window as any).TMap;
  if (!TMap) throw new Error('TMap 未注入');

  const center = new TMap.LatLng(...centerPoint);
  const map = new TMap.Map(containerId, { center, zoom: 17, pitch: 45 });

  map.on('tilesloaded', () => {
    const loading = document.getElementById('loading');
    if (loading) loading.remove();
  });

  return map;
}

export default { createMap };
